package com.crm.system.controller.productManager;

import com.crm.common.model.DataResponse;
import com.crm.common.model.DhPageInfo;
import com.crm.common.model.DhResponse;
import com.crm.common.model.Enum.ResponseCodeEnum;
import com.crm.model.qo.contractManager.ContractRawDataQO;
import com.crm.model.qo.customerManager.MemberCardRawDataQO;
import com.crm.model.vo.customerContractManager.ContractRawDataVO;
import com.crm.model.vo.customerManager.MemberCardRawDataVO;
import com.crm.system.service.contractManager.ContractRawDataService;
import com.crm.system.service.customerManager.MemberCardRawDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @ Author ：pym
 * @ Date   ：2021/7/23 14:39
 */
@RestController
@RequestMapping("/memberCardRawData")
@Slf4j
public class MemberCardRawDataController {
    @Autowired
    private MemberCardRawDataService memberCardRawDataService;

    /**
     * 会员卡原始数据
     * @Author pym
     * @Date  2021/7/23 15:53
     * @param request
     * @param pageIndex -页码
     * @param pageSize -分页大小
     * @param sortName -排序列名字
     * @param sortOrder -排序规则(asc/desc)
     * @param memberCardRawDataQO -查询条件
     * @return {@link {com.crm.common.model.DataResponse}}
     */
    @PostMapping("/memberCardRawDataList")
    public DataResponse memberCardRawDataList(HttpServletRequest request,
                                              @RequestParam(value = "pageIndex", required = true) Integer pageIndex,//页码
                                              @RequestParam(value = "pageSize", required = true) Integer pageSize,//分页大小
                                              @RequestParam(value="sortName",required = false) String sortName,//排序列名字
                                              @RequestParam(value="sortOrder",required = false) String sortOrder,//排序规则(asc/desc)
                                              MemberCardRawDataQO memberCardRawDataQO//查询条件
    ){
        try{
            DhPageInfo<MemberCardRawDataVO> list = memberCardRawDataService.memberCardRawDataList(pageIndex, pageSize, sortName, sortOrder, memberCardRawDataQO);
            return new DhResponse(ResponseCodeEnum.OK.getResponseCode(),list);
        }catch(Exception e){
            log.error("memberCardRawData memberCardRawDataList error:", e);
            return new DhResponse(ResponseCodeEnum.ERROR.getResponseCode());
        }
    }
}
